<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/templates/common/taglib.jsp"%>

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta http-equiv="Access-Control-Allow-Origin" content="*">
<title>${title}</title>
<%@include file="/WEB-INF/templates/common/common.jsp"%>
<script type="text/javascript" src="${basePath}/static/page/js/jqPaginator.js"></script>
<script type="text/javascript" src="${basePath}/static/My97DatePicker/WdatePicker.js"></script>
<script  type="text/javascript" src="${basePath}/static/js/util.js"></script>
<script  type="text/javascript" src="${basePath}/static/layer/layer.js"></script>
<link href="${basePath}/static/layer/layer_style.css" rel="stylesheet" type="text/css">
</head>
<body>
 <!--头部-->
 <%@include file="/WEB-INF/templates/common/header.jsp"%>

<!------导航条-->
 <%@include file="/WEB-INF/templates/common/navigation.jsp"%>

<div class="list_main lay_out">
 <div class="list_DH">
    <!--打印模块导航栏-->
 <%@include file="/WEB-INF/templates/common/printnav.jsp"%>
 </div>
 <div class="list_NR">
  <div class="loc">
   <h3>邮寄详情</h3>
  </div>
 
  <div class="list_con_table"> 
   <div class="search_table">
    <ul id="table_ul">
    <li class="Label_1" style="width:15%">是否邮寄：&nbsp;</li>
    <li class="Label_2"> <input type="radio" class="radio_cl" name='mail' checked="checked" id='' value='1' />未邮&nbsp;&nbsp;
     <input type="radio" class="radio_cl" name='mail' id='' value='2' />已邮</li>
     <li class="Label_1">打印时间：<!-- &nbsp;<span class="Label_6">*</span> --></li>
     <li class="Label_2" style="width:30%;text-align:left">
     <input style="width:44%;margin-left:5px" class="input_box" id="startTime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" type="text"  name=''  value='' /> 
     - <input style="width:44%" class="input_box" id="endTime" onfocus="WdatePicker({dateFmt:'yyyy-MM-dd'})" type="text"  name=''  value='' />
     </li>
    
    <li class="Label_5">
	   <a onclick="findMr(0,10)">查询</a>
	  <!--  <a onclick="exportPrintMailDetailToExcel()">导出</a> -->
    </li>
    </ul>
  </div>
  <table class="Search_tableList" cellpadding="0" cellspacing="0">
		      <tr>
		      <td class="tdLabel_4">病案归属人</td>
		      <td class="tdLabel_4">识别码</td>
		       <td class="tdLabel_4">收件人姓名</td>
		      <td class="tdLabel_4">收件人地址</td>
		      <td class="tdLabel_4">收件人联系方式</td>
		      <td class="tdLabel_4">打印者</td>
		      <td class="tdLabel_4">操作</td>
		      </tr>
		      <tr id="loading" style="height:50px;display:none">
	             <td colspan="6" align="center" ><img src="${basePath}/static/layer/skin/default/loading-2.gif"></td>
	          </tr>
		      <tbody id="tbody">
		
		      </tbody>
     </table>
    <div class="pageList">
       <ul class="pagination clearfix" id="page_plus"></ul>
       <div class="pagination">
            <div>总共：<b id="totalPage">0</b> 条信息    当前页是第 <b id="currentPage">0/0</b>　页</div>
       </div>          
    </div>
 </div>
</div>
</div>
<!--页脚部分-->
<%@include file="/WEB-INF/templates/common/footer.jsp"%>
 <script>
 	function exportPrintMailDetailToExcel(){
 		 var isMail=$('input:radio[name="mail"]:checked').val();
 		 var startTime=$("#startTime").val();
 		 var endTime=$("#endTime").val();
 		$.ajax({
 			type:"post",
 			url:"${basePath}/print/getPrintMailList",
 			data:{mailStatus:isMail,startTime:startTime,endTime:endTime},
 			success:function(data){
	 			if(data.data.listSize>0){
	 				location.href="${basePath}/print/exportMailListToExcel?mailStatus="+isMail+"&startTime="+startTime+"&endTime="+endTime+"";
	 			}else{
	 				layer.alert('导出数据为空!', {icon: 5});
	 			}
 			}
 		})
 	}
 	function findMr(pageNo,pageSize){
 		 var isMail=$('input:radio[name="mail"]:checked').val();
 		 var startTime=$("#startTime").val();
 		 var endTime=$("#endTime").val();
 		 /* if((startTime==""||startTime==null)||(endTime==""||endTime==null)){
 			layer.alert('查询条件不能为空!', {icon: 2});
 			return;
 		 } */
 		//jQuery.support.cors = true;
 		$.ajax({
 			type:"post",
 			url:"${basePath}/print/getPrintMailList",
 			data:{mailStatus:isMail,startTime:startTime,endTime:endTime,pageNo:pageNo,pageSize:pageSize},
 			beforeSend:function(){
 				$("#tbody").html("");
 				$("#loading").show();
 			},
 			success:function(data){
 				$("#loading").hide();
 			if(data.data.count>0){
 				//"address":"北京市朝阳区soho大厦一层302","idCard":"372928195508112219","recipients":"李煜","name":"杨远立","telephone":"15200198765","printPage":7,"printTime":"2017-11-22","operator":"yyl"}],"count":1}}
 				initPage(data.data.count,pageSize,pageNo+1);
 				var printMailList=data.data.printMailList;
 				
 				var html="";
 				for(var i=0;i<printMailList.length;i++){
 					var printMail=printMailList[i];
 					var mailStatus=printMail.mailStatus;
 					var msg = mailStatus==1?"<a class='int' onclick=updateMailStatus("+printMail.pmrId+")>邮寄</a>":"<a class='int'>已邮寄</a>"
 					
 					html+="<tr>"+
 					      " <td  class='tdLabel_5'>"+printMail.name+"</td>"+
 					      " <td  class='tdLabel_5'>"+printMail.mrId+"</td>"+
 					   	  " <td  class='tdLabel_5'>"+printMail.recipients+"</td>"+
 					      " <td  class='tdLabel_5'>"+printMail.address+"</td>"+
 					      " <td  class='tdLabel_5'>"+printMail.telephone+"</td>"+
 					      " <td  class='tdLabel_5'>"+printMail.operator+"</td>"+
 					     " <td  class='tdLabel_5'>"+msg+"</td>"+
 					      "</tr>";
 				}
 				$("#tbody").html(html);
 			}else{
 				layer.alert('查询数据为空!', {icon: 5});
 				$("#tbody").html("");
 				$("#tbody").html("");
                $("#currentPage").html("0/0");
				$("#totalPage").html("0");
				$("#page_plus").html("");	
 			}
 			
 			
 			}
 		})
 	}
 	
 	
 	
 

	
	
	function page(currentPage,totalCounts){
	
	var totalCounts = totalCounts;
 		var pageSize = 10;
 		var totalPages = Math.ceil(totalCounts/pageSize);
 		$("#ston_page_msg").text(totalPages);
 		
 		$("#Pagination").pagination(totalPages,{
 		current_page:currentPage,
 	  callback: function (page_index,jp) {
 		findMr(page_index,pageSize);
 	  } 
 	  
 	  });
	}
	
  //分页
	function initPage(totalCounts,pageSize,currentPage){
		 var visiblePages = 5;
		 var totalPages =Math.ceil(totalCounts/pageSize);
		 $("#totalPage").html(totalCounts);
		 if(totalCounts < 1){
		 	$("#currentPage").html(0+"/"+totalPages);
		 	$("#page_plus").html("");
		 	return;
		 }
		 
         $("#currentPage").html(currentPage+"/"+totalPages);
         
		 $('#page_plus').jqPaginator({

		        totalCounts: totalCounts,
		        pageSize:pageSize,
		        visiblePages: visiblePages,
		        currentPage: currentPage,

		        first:'<li class="first"><a href="javascript:void(0);">首页</a></li>',
		        prev: '<li class="prev"><a href="javascript:void(0);">上一页</a></li>',
		        next: '<li class="next"><a href="javascript:void(0);">下一页</a></li>',
		        last: '<li class="last"><a href="javascript:void(0);">末页</a></li>',
		        page: '<li class="page"><a href="javascript:void(0);">{{page}}</a></li>',
		        onPageChange: function (page,type) {
		        	if(type !='init'){
		        		findMr(page-1,pageSize);
			        }
		        }
		    });

	}	

  
  	function updateMailStatus(pmrId){
  		$.ajax({
  			type:"post",
  			url:"${basePath}/print/updatePrintMailStatus",
  			data:{printMailRecordId:pmrId},
  			success:function(data){
  				layer.alert(data.msg, {icon: 6});
  				if(data.success){
  					window.location.href="${basePath}/print/queryPrintMailDetailPage";
  				}
  			}
  		})
  	}
	 
	
	</script>

</body>
</html>
